#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;

class MinStack
{
public:
    int stk[20005], head = -1, helperStk[20005], helperHead = -1;
    void push(int x)
    {
        stk[++head] = x;
        if (helperHead == -1 || helperStk[helperHead] >= x)
            helperStk[++helperHead] = x;
    }
    void pop()
    {
        if (stk[head] == helperStk[helperHead])
            helperHead--;
        head--;
    }
    int top()
    {
        return stk[head];
    }
    int min()
    {
        return helperStk[helperHead];
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(x);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->min();
 */